package com.gxa.controller.cangkucontroller;

import com.gxa.common.R;
import com.gxa.pojo.*;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @author zhl
 * @date 2022/3/31 11:23
 */
@Controller
@Api(value = "用户模块数据测试",tags = "仓库模块接口API")
@RequiresPermissions(value = {"调拨单", "库存查询"}, logical = Logical.OR)
@RequestMapping("/cangKu")

public class CangKuController {

    @Autowired
    public R r;
    //1.选择商品
    @ResponseBody
    @RequestMapping(value = "/selectShangPin",method = RequestMethod.GET)
    @ApiOperation(value = "选择商品接口",notes = "根据条件选择商品",httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "selectShangPin",value = "选择商品",required = false,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",required = true,dataType = "int",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="参数格式不对"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })

    public R selectShangPin(@ApiParam(name ="selectShangPin",value = "选择商品") String selectShangPin,
                            @RequestParam @ApiParam(name ="currentPage",value = "当前页码数") int currentPage,
                            @RequestParam @ApiParam(name ="pageSize",value = "每页显示条数") int pageSize
    ){
        r.setCode(200);
        r.setMsg("查询成功");
        List<ShangPin> list = new ArrayList<>();

        ShangPin shangPin = new ShangPin();


        shangPin.setShangPinBianHao("123124");
        shangPin.setShangPinMingCheng("qweq");
        shangPin.setGuiGeXingHao("123123");
        Unit unit = new Unit();
        unit.setUnitName("个");
        shangPin.setUnit(unit);
        list.add(shangPin);

        shangPin = new ShangPin();
        shangPin.setShangPinBianHao("asdf");
        shangPin.setShangPinMingCheng("洗衣粉");
        shangPin.setGuiGeXingHao("123");
        unit = new Unit();
        unit.setUnitName("包");
        shangPin.setUnit(unit);
        list.add(shangPin);

        r.setData(list);
        return r;
    }

    //2.选择调出仓库
    @RequestMapping(value = "/diaoChuCangKu",method = RequestMethod.GET)
    @ApiOperation(value = "选择调出仓库接口",notes = "选择调出仓库",httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "diaoChuCangKu",value = "选择调出仓库",required = true,dataType = "String",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="参数格式不对"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R diaoChuCangKu(@RequestParam @ApiParam(name ="diaoChuCangKu",value = "选择调出仓库",required = true) String selectCangKu){
        r.setCode(200);
        r.setMsg("查询成功");
        List<CangKu> list =new ArrayList<>();
        CangKu cangKu = new CangKu();
        cangKu.setCangKuName("测试仓库");
        list.add(cangKu);
        r.setData(list);
        return r;
    }

    //3.选择调入仓库
    @RequestMapping(value = "/diaoRuCangKu",method = RequestMethod.GET)
    @ApiOperation(value = "选择调入仓库接口",notes = "选择调入仓库",httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "diaoRuCangKu",value = "选择调入仓库",required = true,dataType = "String",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="参数格式不对"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R diaoRuCangKu(@RequestParam @ApiParam(name ="diaoRuCangKu",value = "选择调入仓库",required = true) String selectCangKu){
        r.setCode(200);
        r.setMsg("查询成功");
        List<CangKu> list =new ArrayList<>();
        CangKu cangKu = new CangKu();
        cangKu.setCangKuName("白云仓");
        list.add(cangKu);
        r.setData(list);
        return r;
    }

    //4.查询库存
    @RequestMapping(value = "/selectChoice",method = RequestMethod.GET)
    @ApiOperation(value = "查询接口",notes = "查库存",httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cangKuName",value = "仓库名称",dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "shangPinType",value = "商品类别",dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "selectShangPin",value = "商品信息",dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",required = true,dataType = "int",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="参数格式不对"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R selectChoice(@ApiParam(name ="cangKuName",value = "仓库名称") String cangKuName,
                          @ApiParam(name ="shangPinType",value = "商品类别") String shangPinType,
                          @ApiParam(name ="selectShangPin",value = "商品信息") String selectShangPin,
                          @RequestParam @ApiParam(name ="currentPage",value = "当前页码数",required = true) int currentPage,
                          @RequestParam @ApiParam(name ="pageSize",value = "每页显示条数",required = true) int pageSize
    ){
        r.setCode(200);
        r.setMsg("查询成功");
        List<ShangPinCangKu> shangPinCangKus = new ArrayList<>();
        List<ShangPin> shangPinList = new ArrayList<>();

        ShangPinCangKu shangPinCangKu = new ShangPinCangKu();
        CangKu cangKu = new CangKu();
        ShangPin shangPin = new ShangPin();
        Unit unit = new Unit();
        ShangPinType shangPinTypeName = new ShangPinType();

        unit.setUnitName("个");
        shangPinCangKu.setUnit(unit);

        shangPinTypeName.setShangPinType("123123");
        shangPinCangKu.setShangPinType(shangPinTypeName);

        shangPin.setShangPinMingCheng("asdqdwq");
        shangPin.setShangPinBianHao("1231");
        shangPin.setGuiGeXingHao("1234");

        shangPinList.add(shangPin);
        shangPinCangKu.setXiTongKuCun(BigDecimal.valueOf(123));
        shangPinCangKu.setCangKuId(1);
        shangPinCangKu.setShangPinList(shangPinList);

        shangPinCangKus.add(shangPinCangKu);
        r.setData(shangPinCangKus);


        return r;
    }



    //5.保存调拨单
    @RequestMapping(value = "/baoCunDiaoBoDan",method = RequestMethod.POST)
    @ApiOperation(value = "保存调拨单接口",notes = "保存调拨单",httpMethod = "post", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "danJuRiQi",value = "单据日期",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "danJuBianHao",value = "单据编号",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "shangPin",value = "商品名称",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "shuLiang",value = "数量",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "diaoChuCangKu",value = "调出仓库名",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "diaoRuCangKu",value = "调入仓库名",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "beiZhu",value = "备注",dataType = "String",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="参数格式不对"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R insertDiaoBoDan(@RequestParam @ApiParam(name ="danJuRiQi",value = "单据日期",required = true) String danJuRiQi,
                             @RequestParam @ApiParam(name = "danJuBianHao",value = "单据编号",required = true) String danJuBianHao,
                             @RequestParam @ApiParam(name = "shangPin",value = "商品名称",required = true) String shangPin,
                             @RequestParam @ApiParam(name = "shuLiang",value = "数量",required = true) String shuLiang,
                             @RequestParam @ApiParam(name = "diaoChuCangKu",value = "调出仓库名",required = true) String diaoChuCangKu,
                             @RequestParam @ApiParam(name = "diaoRuCangKu",value = "调入仓库名",required = true) String diaoRuCangKu,
                             @ApiParam(name = "beiZhu",value = "备注") String beiZhu
    ){
        r.setCode(200);
        r.setMsg("保存成功");
        return r;
    }


    //6.审核调拨单
    @RequestMapping(value = "/shenHeDiaoBoDan",method = RequestMethod.POST)
    @ApiOperation(value = "审核接口",notes = "审核调拨单",httpMethod = "post", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "danJuRiQi",value = "单据日期",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "danJuBianHao",value = "单据编号",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "shangPin",value = "商品名称",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "shuLiang",value = "数量",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "diaoChuCangKu",value = "调出仓库名",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "diaoRuCangKu",value = "调入仓库名",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "beiZhu",value = "备注",dataType = "String",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="参数格式不对"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R shenHeDiaoBoDan(@RequestParam @ApiParam(name ="danJuRiQi",value = "单据日期",required = true) String danJuRiQi,
                             @RequestParam @ApiParam(name = "danJuBianHao",value = "单据编号",required = true) String danJuBianHao,
                             @RequestParam @ApiParam(name = "shangPin",value = "商品名称",required = true) String shangPin,
                             @RequestParam @ApiParam(name = "shuLiang",value = "数量",required = true) String shuLiang,
                             @RequestParam @ApiParam(name = "diaoChuCangKu",value = "调出仓库名",required = true) String diaoChuCangKu,
                             @RequestParam @ApiParam(name = "diaoRuCangKu",value = "调入仓库名",required = true) String diaoRuCangKu,
                             @ApiParam(name = "beiZhu",value = "备注") String beiZhu
    ){
        r.setCode(200);
        r.setMsg("审核成功");
        return r;
    }



    //7.修改调拨单
    @RequestMapping(value = "/updateDiaoBoDan",method = RequestMethod.POST)
    @ApiOperation(value = "修改调拨单接口",notes = "修改调拨单",httpMethod = "post", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "danJuRiQi",value = "单据日期",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "shangPin",value = "商品名称",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "shuLiang",value = "数量",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "unit",value = "单位",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "diaoChuCangKu",value = "调出仓库名",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "diaoRuCangKu",value = "调入仓库名",required = true,dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "beiZhu",value = "备注",dataType = "String",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="参数格式不对"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R updateDiaoBoDan(@ApiParam(name ="danJuRiQi",value = "单据日期",required = false) String danJuRiQi,
                             @RequestParam @ApiParam(name = "shangPin",value = "商品名称",required = true) String shangPin,
                             @RequestParam @ApiParam(name = "shuLiang",value = "数量",required = true) String shuLiang,
                             @RequestParam @ApiParam(name = "unit",value = "单位",required = true) String danWei,
                             @RequestParam @ApiParam(name = "diaoChuCangKu",value = "调出仓库名",required = true) String diaoChuCangKu,
                             @RequestParam @ApiParam(name = "diaoRuCangKu",value = "调入仓库名",required = true) String diaoRuCangKu,
                             @ApiParam(name = "beiZhu",value = "备注") String beiZhu
    ){
        r.setCode(200);
        r.setMsg("修改成功");
        return r;
    }


    //8.查询调拨单记录
    @RequestMapping(value = "/selectDiaoBoDanJiLu",method = RequestMethod.GET)
    @ApiOperation(value = "查询调拨单记录接口",notes = "查询调拨单记录",httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "danJuRiQi",value = "单据日期",required = true, dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "danJuBianHao",value = "单据编号",dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "keHuName",value = "客户名称",dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "diaoChuCangKu",value = "调出仓库名",dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "diaoRuCangKu",value = "调入仓库名",dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "beiZhu",value = "备注",dataType = "String",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="参数格式不对"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R selectDiaoBoDanJiLu(@RequestParam @ApiParam(name ="danJuRiQi",value = "单据日期",required = true) String danJuRiQi,
                                 @ApiParam(name = "danJuBianHao",value = "单据编号") String danJuBianHao,
                                 @ApiParam(name = "keHuName",value = "客户名称") String shangPin,
                                 @ApiParam(name = "diaoChuCangKu",value = "调出仓库名") String diaoChuCangKu,
                                 @ApiParam(name = "diaoRuCangKu",value = "调入仓库名") String diaoRuCangKu,
                                 @ApiParam(name = "beiZhu",value = "备注") String beiZhu
    ){
        r.setCode(200);
        r.setMsg("查询成功");
        List<ShangPinDanJu> shangPinDanJus = new ArrayList<>();
        List<ShangPin> shangPinList = new ArrayList<>();

        ShangPinDanJu shangPinDanJu = new ShangPinDanJu();
        ShangPin shangPin1 =new ShangPin();
        Unit unit = new Unit();

        unit.setUnitName("瓶");
        shangPinDanJu.setUnit(unit);

        shangPin1.setShangPinMingCheng("123456");
        shangPinDanJu.setShangPin(shangPin1);

        shangPinDanJu.setShuLiang(34);
        shangPinDanJu.setDiaoChuCangKuId(1);
        shangPinDanJu.setDiaoRuCangKuId(2);
        shangPinDanJus.add(shangPinDanJu);
        r.setData(shangPinDanJus);
        return r;
    }


    //9.删除
    @RequestMapping(value = "/delete",method = RequestMethod.POST)
    @ApiOperation(value = "删除接口",notes = "根据条件选择商品",httpMethod = "post", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "根据id来删除",required = true,dataType = "int",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=400,message="参数格式不对"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R delete(@RequestParam @ApiParam(name ="delete",value = "删除",required = true) String delete){
        r.setCode(200);
        r.setMsg("删除成功");
        return r;
    }

}
